package com.wpzf.zxhc.controller;

import com.wpzf.common.core.utils.ServletUtils;
import com.wpzf.common.core.web.domain.AjaxResult;
import com.wpzf.common.security.service.TokenService;
import com.wpzf.common.security.utils.SecurityUtils;
import com.wpzf.system.api.model.LoginUser;
import com.wpzf.zxhc.utils.*;
import com.wpzf.zxhc.domain.*;
import com.wpzf.zxhc.mapper.XjtbTbBaseMapper;
import com.wpzf.zxhc.service.AppService;
import com.wpzf.zxhc.service.WpzfTbBaseService;
import com.wpzf.zxhc.service.WpzfTbhcjgService;
import com.wpzf.zxhc.service.XjtbTbBaseService;
import net.lingala.zip4j.exception.ZipException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import shade.okhttp3.OkHttpClient;
import shade.okhttp3.Request;
import shade.okhttp3.Response;

import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/xjtbtb")
public class XjtbTbBaseInfoController {
    @Autowired
    WpzfTbBaseService wpzfTbBaseService;

    @Autowired
    WpzfTbhcjgService wpzfTbhcjgService;

    @Autowired
    XjtbTbBaseService xjtbTbBaseService;

    @Autowired
    XjtbTbBaseMapper xjtbTbBaseMapper;

    @Autowired
    AppService appService;

    @Autowired
    TokenService tokenService;

    MultipleFileUnZip multipleFileUnZip = new MultipleFileUnZip();

    @Value("${tempath}")
    public String tempath;

    //按照行政区划获取所有图斑信息
    @RequestMapping(value = "/queryTbByxzqh", method = RequestMethod.POST)
    public AjaxResult queryTbByxzqh(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = SecurityUtils.getLoginUser();
            String xzqdmjq = loginUser.getSysUser().getXzqdmjq();
            String[] xzqdmjqArray = null;
            if (xzqdmjq != null && !"".equals(xzqdmjq)) {
                xzqdmjqArray = xzqdmjq.split(",");
            }
            parm.put("xzqdmjqArray", xzqdmjqArray);

            String operName = SecurityUtils.getUsername();
            parm.put("username", operName);
            //获取图斑列表
            List<WpCjTbxxbxj2023DTO> wpCjTbxxb2023DTOS = xjtbTbBaseService.queryTbByxzqh(parm);
            Integer cnt = xjtbTbBaseMapper.queryTbByxzqhCount(parm);
            if (wpCjTbxxb2023DTOS != null) {
                return AjaxResult.success("获取成功", wpCjTbxxb2023DTOS, cnt);
            } else {
                return AjaxResult.error("获取失败");
            }
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/queryTbInfoByIndex", method = RequestMethod.POST)
    public AjaxResult queryTbInfoByIndex(@RequestBody Map<String, Object> parm) {
        try {
            //获取图斑列表
            List<WpCjTbxxbxj2023DTO> wpCjTbxxb2023DTOS = xjtbTbBaseService.queryTbInfoByIndex(parm);
            if (wpCjTbxxb2023DTOS != null) {
                return AjaxResult.success("获取成功", wpCjTbxxb2023DTOS);
            } else {
                return AjaxResult.error("获取失败");
            }
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //按照行政区划获取所有图斑信息
    @RequestMapping(value = "/getYtbcount", method = RequestMethod.POST)
    public AjaxResult getYtbcount(@RequestBody Map<String, Object> parm) {
        try {
            //获取图斑列表
            Integer cnt = xjtbTbBaseMapper.queryTbByxzqhCountytb(parm);
            if (cnt != null) {
                return AjaxResult.success("获取成功", cnt);
            } else {
                return AjaxResult.error("获取失败");
            }
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //按照行政区划获取所有图斑信息
    @RequestMapping(value = "/getzcount", method = RequestMethod.POST)
    public AjaxResult getzcount(@RequestBody Map<String, Object> parm) {
        try {
            //获取图斑列表
            Integer cnt = xjtbTbBaseMapper.getzcount(parm);
            if (cnt != null) {
                return AjaxResult.success("获取成功", cnt);
            } else {
                return AjaxResult.error("获取失败");
            }
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    public String method(Object object) {
        String obj = object != null ? object.toString() : "";
        return obj;
    }

    //获取图斑信息
    @RequestMapping(value = "/queryUserByHctbId", method = RequestMethod.POST)
    public AjaxResult queryUserByHctbId(@RequestBody Map<String, Object> parm) {
        String jcbh = parm.get("jcbh") + "";
        if (jcbh.indexOf(",") != -1) {
            parm.put("jcbh", jcbh.split(",")[0]);
        }
        try {
            WpCjTbBaseinfoxjDTO wpCjTbBaseinfoxjDTO = new WpCjTbBaseinfoxjDTO();

            //图斑基本信息
            WpCjTbxxbxj2023DTO wpCjTbxxbxj2023DTO = xjtbTbBaseService.querytbxxByjcbh(parm);
            wpCjTbBaseinfoxjDTO.setWpCjTbxxbxj2023DTO(wpCjTbxxbxj2023DTO);

            //图斑举证照片
            parm.put("sfzz","自主提取".equals(wpCjTbxxbxj2023DTO.getGjxfhzztq())?"1":"0");
            WpCjGsinfoly2024DTO gsinfoly = xjtbTbBaseService.getGsinfoly(parm);

            wpCjTbBaseinfoxjDTO.setWpCjGsinfoly2024DTO(gsinfoly);

            ModelMap modelMap = new ModelMap();
            if ("0".equals(gsinfoly.getInfoly())) {
                modelMap = xjtbTbBaseService.getShowImgsnew(parm);
            } else if ("1".equals(gsinfoly.getInfoly())) {
                List<String> list = new ArrayList<>();
                try {
                    parm.put("dkbh", parm.get("tbbh").toString());
                } catch (Exception ex) {
                    parm.put("tbbh", parm.get("jcbh").toString());
                    parm.put("dkbh", parm.get("jcbh").toString());
                }
                list.add(appService.getInfo(parm));
//                System.out.println(list);
                modelMap.put("data", list);
            }
            wpCjTbBaseinfoxjDTO.setModelMap(modelMap);

            //获取地块信息
            List<WpCjDkxxbxj2023DTO> dkxxbxj2023DTOS = xjtbTbBaseService.queryWpCjDkInfoByJcbh(parm);
            /*List<WpCjDkpw2023DTO> lists = new ArrayList<>();
            if (dkxxbxj2023DTOS.size() > 0) {
                for (int i = 0; i < dkxxbxj2023DTOS.size(); i++) {
                    lists = new ArrayList<>();
                    WpCjDkxxbxj2023DTO model = dkxxbxj2023DTOS.get(i);
                    if (!("null").equals(model.getNydzypzwh()) && !("").equals(model.getNydzypzwh()) && model.getNydzypzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getNydzypzwh()).split(","); //批准文号
                        String[] pwlyarr = method(model.getNydzypwly()).split(",");
                        String[] pzmjarr = method(model.getNydzypzmj()).split(",");
                        String[] pzrqarr = method(model.getNydzypzrq()).split(",");

                        //江西没有
                        String[] tdgypwlxejlarr = method(model.getNydzytdgypwlxejl()).split(",");
                        String[] pwlbarr = method(model.getNydzypwlb()).split(",");
                        String[] pznydmjarr = method(model.getNydzypznydmj()).split(",");
                        String[] pzgdmjarr = method(model.getNydzypzgdmj()).split(",");
                        String[] pzyjjbntmjarr = method(model.getNydzypzyjjbntmj()).split(",");

                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("农用地转用");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "") {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "") {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "") {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "") {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "") {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "") {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "") {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "") {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getZjggpzwh()) && !("").equals(model.getZjggpzwh()) && model.getZjggpzwh() != null) //增加挂钩批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getZjggpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getZjggtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getZjggpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getZjggpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getZjggpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getZjggpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getZjggpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getZjggpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getZjggpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("增减挂钩");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "") {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "") {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "") {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "") {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "") {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "") {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "") {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "") {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getGkfqdpzwh()) && !("").equals(model.getGkfqdpzwh()) && model.getGkfqdpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getGkfqdpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getGkfqdtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getGkfqdpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getGkfqdpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getGkfqdpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getGkfqdpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getGkfqdpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getGkfqdpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getGkfqdpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("工矿废弃地");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "") {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "") {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "") {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "") {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "") {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "") {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "") {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "") {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getBdcqzspzwh()) && !("").equals(model.getBdcqzspzwh()) && model.getBdcqzspzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getBdcqzspzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getBdcqzstdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getBdcqzspwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getBdcqzspzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getBdcqzspwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getBdcqzspzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getBdcqzspznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getBdcqzspzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getBdcqzspzzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("不动产权证书");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "") {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "") {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "") {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "") {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "") {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "") {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "") {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "") {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getSsnydpzwh()) && !("").equals(model.getSsnydpzwh()) && model.getSsnydpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getSsnydpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getSsnydtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getSsnydpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getSsnydpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getSsnydpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getSsnydpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getSsnydpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getSsnydpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getSsnydpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("设施农用地");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "") {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "") {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "") {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "") {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "") {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "") {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "") {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "") {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getTdzzyspzwh()) && !("").equals(model.getTdzzyspzwh()) && model.getTdzzyspzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getTdzzyspzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getTdzzystdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getTdzzyspwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getTdzzyspzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getTdzzyspwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getTdzzyspzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getTdzzyspznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getTdzzyspzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getTdzzyspzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("土地整治验收");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "") {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "") {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "") {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "") {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "") {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "") {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "") {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "") {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getLsydpzwh()) && !("").equals(model.getLsydpzwh()) && model.getLsydpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getLsydpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getLsydtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getLsydpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getLsydpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getLsydpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getLsydpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getLsydpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getLsydpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getLsydpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("临时用地");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "") {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "") {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "") {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "") {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "") {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "") {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "") {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "") {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getTdgypzwh()) && !("").equals(model.getTdgypzwh()) && model.getTdgypzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getTdgypzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getTdgytdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getTdgypwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getTdgypzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getTdgypwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getTdgypzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getTdgypznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getTdgypzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getTdgypzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("土地供应");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "") {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "") {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "") {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "") {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "") {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "") {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "") {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "") {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getXxydpzwh()) && !("").equals(model.getXxydpzwh()) && model.getXxydpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getXxydpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getXxydtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getXxydpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getXxydpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getXxydpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getXxydpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getXxydpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getXxydpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getXxydpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("先行用地");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "") {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "") {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "") {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "") {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "") {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "") {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "") {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "") {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getYspzwh()) && !("").equals(model.getYspzwh()) && model.getYspzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getYspzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getYstdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getYspwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getYspzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getYspwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getYspzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getYspznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getYspzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getYspzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("预审");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "") {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "") {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "") {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "") {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "") {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "") {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "") {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "") {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getQtpzwh()) && !("").equals(model.getQtpzwh()) && model.getQtpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getQtpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getQttdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getQtpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getQtpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getQtpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getQtpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getQtpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getQtpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getQtpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("其他");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "") {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "") {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "") {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "") {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "") {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "") {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "") {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "") {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }


                    model.setHfpwlist(lists);
                }
            }*/
            wpCjTbBaseinfoxjDTO.setWpCjDkxxbxj2023List(dkxxbxj2023DTOS);


            //获取图斑截图
            List<WpCjTbjt2023DTO> wpCjTbjt2023DTOS = xjtbTbBaseService.querytbjtBytbbhsheng1(parm);
            wpCjTbBaseinfoxjDTO.setWpCjTbjt2023DTOS(wpCjTbjt2023DTOS);


            return AjaxResult.success("获取成功", wpCjTbBaseinfoxjDTO);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }


    @RequestMapping(value = "/queryUserByHctbIdxj", method = RequestMethod.POST)
    public AjaxResult queryUserByHctbIdxj(@RequestBody Map<String, Object> parm) {
        String jcbh = parm.get("jcbh") + "";
        if (jcbh.indexOf(",") != -1) {
            parm.put("jcbh", jcbh.split(",")[0]);
        }
        try {
            WpCjTbBaseinfoxjDTO wpCjTbBaseinfoxjDTO = new WpCjTbBaseinfoxjDTO();

            //图斑基本信息
            WpCjTbxxbxj2023DTO wpCjTbxxbxj2023DTO = xjtbTbBaseService.querytbxxByjcbh(parm);
            wpCjTbBaseinfoxjDTO.setWpCjTbxxbxj2023DTO(wpCjTbxxbxj2023DTO);

            //图斑举证照片
            parm.put("sfzz","自主提取".equals(wpCjTbxxbxj2023DTO.getGjxfhzztq())?"1":"0");
            WpCjGsinfoly2024DTO gsinfoly = xjtbTbBaseService.getGsinfoly(parm);

            wpCjTbBaseinfoxjDTO.setWpCjGsinfoly2024DTO(gsinfoly);

            ModelMap modelMap = new ModelMap();
            if ("0".equals(gsinfoly.getInfoly())) {
                modelMap = xjtbTbBaseService.getShowImgsnew(parm);
            } else if ("1".equals(gsinfoly.getInfoly())) {
                List<String> list = new ArrayList<>();
                list.add(appService.getInfo(parm));
//                System.out.println(list);
                modelMap.put("data", list);
            }
            wpCjTbBaseinfoxjDTO.setModelMap(modelMap);

            //获取地块信息
            List<WpCjDkxxbxj2023DTO> dkxxbxj2023DTOS = xjtbTbBaseService.queryWpCjDkInfoByJcbh(parm);
            /*List<WpCjDkpw2023DTO> lists = new ArrayList<>();
            if (dkxxbxj2023DTOS.size() > 0) {
                for (int i = 0; i < dkxxbxj2023DTOS.size(); i++) {
                    lists = new ArrayList<>();
                    WpCjDkxxbxj2023DTO model = dkxxbxj2023DTOS.get(i);
                    if (!("null").equals(model.getNydzypzwh()) && !("").equals(model.getNydzypzwh()) && model.getNydzypzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getNydzypzwh()).split(","); //批准文号
                        String[] pwlyarr = method(model.getNydzypwly()).split(",");
                        String[] pzmjarr = method(model.getNydzypzmj()).split(",");
                        String[] pzrqarr = method(model.getNydzypzrq()).split(",");

                        //江西没有
                        String[] tdgypwlxejlarr = method(model.getNydzytdgypwlxejl()).split(",");
                        String[] pwlbarr = method(model.getNydzypwlb()).split(",");
                        String[] pznydmjarr = method(model.getNydzypznydmj()).split(",");
                        String[] pzgdmjarr = method(model.getNydzypzgdmj()).split(",");
                        String[] pzyjjbntmjarr = method(model.getNydzypzyjjbntmj()).split(",");

                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("农用地转用");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getZjggpzwh()) && !("").equals(model.getZjggpzwh()) && model.getZjggpzwh() != null) //增加挂钩批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getZjggpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getZjggtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getZjggpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getZjggpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getZjggpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getZjggpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getZjggpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getZjggpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getZjggpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("增减挂钩");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getGkfqdpzwh()) && !("").equals(model.getGkfqdpzwh()) && model.getGkfqdpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getGkfqdpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getGkfqdtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getGkfqdpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getGkfqdpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getGkfqdpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getGkfqdpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getGkfqdpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getGkfqdpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getGkfqdpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("工矿废弃地");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getBdcqzspzwh()) && !("").equals(model.getBdcqzspzwh()) && model.getBdcqzspzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getBdcqzspzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getBdcqzstdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getBdcqzspwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getBdcqzspzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getBdcqzspwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getBdcqzspzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getBdcqzspznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getBdcqzspzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getBdcqzspzzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("不动产权证书");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getSsnydpzwh()) && !("").equals(model.getSsnydpzwh()) && model.getSsnydpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getSsnydpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getSsnydtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getSsnydpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getSsnydpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getSsnydpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getSsnydpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getSsnydpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getSsnydpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getSsnydpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("设施农用地");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getTdzzyspzwh()) && !("").equals(model.getTdzzyspzwh()) && model.getTdzzyspzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getTdzzyspzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getTdzzystdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getTdzzyspwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getTdzzyspzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getTdzzyspwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getTdzzyspzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getTdzzyspznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getTdzzyspzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getTdzzyspzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("土地整治验收");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getLsydpzwh()) && !("").equals(model.getLsydpzwh()) && model.getLsydpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getLsydpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getLsydtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getLsydpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getLsydpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getLsydpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getLsydpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getLsydpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getLsydpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getLsydpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("临时用地");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getTdgypzwh()) && !("").equals(model.getTdgypzwh()) && model.getTdgypzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getTdgypzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getTdgytdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getTdgypwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getTdgypzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getTdgypwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getTdgypzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getTdgypznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getTdgypzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getTdgypzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("土地供应");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getXxydpzwh()) && !("").equals(model.getXxydpzwh()) && model.getXxydpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getXxydpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getXxydtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getXxydpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getXxydpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getXxydpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getXxydpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getXxydpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getXxydpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getXxydpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("先行用地");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getYspzwh()) && !("").equals(model.getYspzwh()) && model.getYspzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getYspzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getYstdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getYspwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getYspzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getYspwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getYspzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getYspznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getYspzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getYspzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("预审");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getQtpzwh()) && !("").equals(model.getQtpzwh()) && model.getQtpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getQtpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getQttdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getQtpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getQtpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getQtpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getQtpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getQtpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getQtpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getQtpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("其他");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }


                    model.setHfpwlist(lists);
                }
            }*/
            wpCjTbBaseinfoxjDTO.setWpCjDkxxbxj2023List(dkxxbxj2023DTOS);


            //获取图斑截图
            List<WpCjTbjt2023DTO> wpCjTbjt2023DTOS = xjtbTbBaseService.querytbjtBytbbhsheng1(parm);
            wpCjTbBaseinfoxjDTO.setWpCjTbjt2023DTOS(wpCjTbjt2023DTOS);

            System.out.println(wpCjTbBaseinfoxjDTO);
            return AjaxResult.success("获取成功", wpCjTbBaseinfoxjDTO);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }


    //图斑拆分 暂存按钮
    @RequestMapping(value = "/saveDkxxbXj", method = RequestMethod.POST)
    public AjaxResult saveDkxxbXj(@RequestBody Map<String, Object> parm) {
        Integer rest = xjtbTbBaseService.saveDkxxbXj(parm);
        if (rest > 0) {
            return AjaxResult.success("暂存 成功", rest);
        }
        return AjaxResult.error("暂存 失败", -1);
    }

    //图斑拆分 确认提交按钮
    @RequestMapping(value = "/addDkxxbXjDatamj", method = RequestMethod.POST)
    public AjaxResult addDkxxbXjDatamj(@RequestBody Map<String, Object> parm) {
        Integer rest = xjtbTbBaseService.addDkxxbXjDatamj(parm);
        if (rest > 0) {
            return AjaxResult.success("图斑拆分成功", rest);
        }
        return AjaxResult.error("图斑拆分失败");
    }

    //获取已填报图斑信息
    @RequestMapping(value = "/queryYtbTbInfo", method = RequestMethod.POST)
    public AjaxResult queryYtbTbInfo(@RequestBody Map<String, Object> parm) {
        try {
            List<YtbTbInfo> list = xjtbTbBaseService.queryYtbTbInfo(parm);
            Integer cnt = xjtbTbBaseService.queryYtbTbInfoCount(parm);
            return AjaxResult.success("获取成功", list, cnt);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/queryYtbTbInfoByIndex", method = RequestMethod.POST)
    public AjaxResult queryYtbTbInfoByIndex(@RequestBody Map<String, Object> parm) {
        try {
            List<Integer> lstDkzt = new ArrayList<>();
            String dkzts = parm.get("dkzt") + "";
            if (!dkzts.isEmpty() && !"null".equals(dkzts)) {
                for (String zt : dkzts.split(",")) {
                    lstDkzt.add(Integer.parseInt(zt.replace("'", "")));
                }
                parm.put("lstDkzt", lstDkzt);
            }
            YtbTbInfo ytbTbInfo = xjtbTbBaseService.queryYtbTbInfoByIndex(parm);
            return AjaxResult.success("获取成功", ytbTbInfo);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //
    @RequestMapping(value = "/queryYtjTbInfoByIndex", method = RequestMethod.POST)
    public AjaxResult queryYtjTbInfoByIndex(@RequestBody Map<String, Object> parm) {
        try {
            YtbTbInfo ytbTbInfo = xjtbTbBaseService.queryYtjTbInfoByIndex(parm);
            return AjaxResult.success("获取成功", ytbTbInfo);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //获取已提交图斑信息
    @RequestMapping(value = "/queryYtjTbInfo", method = RequestMethod.POST)
    public AjaxResult queryYtjTbInfo(@RequestBody Map<String, Object> parm) {
        try {
            List<YtbTbInfo> list = xjtbTbBaseService.queryYtjTbInfo(parm);
            Integer cnt = xjtbTbBaseService.queryYtjTbInfoCount(parm);
            return AjaxResult.success("获取成功", list, cnt);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }


    //获取已提交批次号
    @RequestMapping(value = "/getYtjPch", method = RequestMethod.GET)
    public AjaxResult getYtjPch(@RequestBody Map<String, Object> parm) {
        try {
//            Map parm = new HashMap();
//            parm.put("xzqdm", SecurityUtils.getUsername());
            List<Map> list = xjtbTbBaseService.getYtjPch(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //获取批次号
    @RequestMapping(value = "/getPch", method = RequestMethod.POST)
    public AjaxResult getPch(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = xjtbTbBaseService.getPch(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //获取行政区代码
    @RequestMapping(value = "/getXzq", method = RequestMethod.POST)
    public AjaxResult getXzq(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = SecurityUtils.getLoginUser();
            String xzqdmjq = loginUser.getSysUser().getXzqdmjq();
            String[] xzqdmjqArray = null;
            if (xzqdmjq != null && !"".equals(xzqdmjq)) {
                xzqdmjqArray = xzqdmjq.split(",");
            }
            parm.put("xzqdmjqArray", xzqdmjqArray);
            List<Map> list = xjtbTbBaseService.getXzq(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //获取行政区代码
    @RequestMapping(value = "/getXzqmc", method = RequestMethod.POST)
    public AjaxResult getXzqmc(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = xjtbTbBaseService.getXzqmc(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getdkXzq", method = RequestMethod.POST)
    public AjaxResult getdkXzq(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = SecurityUtils.getLoginUser();
            String xzqdmjq = loginUser.getSysUser().getXzqdmjq();
            String[] xzqdmjqArray = null;
            if (xzqdmjq != null && !"".equals(xzqdmjq)) {
                xzqdmjqArray = xzqdmjq.split(",");
            }
            parm.put("xzqdmjqArray", xzqdmjqArray);
            List<Map> list = xjtbTbBaseService.getdkXzq(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //获取行政区代码
    @RequestMapping(value = "/getdkXzqmc", method = RequestMethod.POST)
    public AjaxResult getdkXzqmc(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = xjtbTbBaseService.getdkXzqmc(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //获取已填报批次号
    @RequestMapping(value = "/getYtbPch", method = RequestMethod.POST)
    public AjaxResult getYtbPch(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = xjtbTbBaseService.getYtbPch(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //获取已提交批次号
    @RequestMapping(value = "/taskSubmit", method = RequestMethod.POST)
    public AjaxResult taskSubmit(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("username", loginUser.getUsername());
            parm.put("realname", loginUser.getSysUser().getNickName());
            Integer nNotSave = xjtbTbBaseService.getNotSaveCount(parm);
            if (nNotSave == 0) {
                Integer nUpdate = xjtbTbBaseService.updateTask(parm);
                return AjaxResult.success("提交成功", nUpdate);
            }
            return AjaxResult.success("当前区县未填报完成，无法提交！", 0);
        } catch (Exception ex) {
            return AjaxResult.error("提交失败", ex.toString());
        }
    }

    //保存县级地块信息表
    @RequestMapping(value = "/addDkxxbXjData", method = RequestMethod.POST)
    public AjaxResult addDkxxbXjData(@RequestBody Map<String, Object> parm) {
        Integer rest = xjtbTbBaseService.addDkxxbXjData(parm);
        if (rest > 0) {
            return AjaxResult.success("地块信息保存成功", rest);
        }
        return AjaxResult.error("地块信息保存失败");
    }


    //保存县级地块信息表
    @RequestMapping(value = "/addDkxxbXjDatadg", method = RequestMethod.POST)
    public AjaxResult addDkxxbXjDatadg(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("czr", loginUser.getUsername());
        parm.put("realname", loginUser.getSysUser().getNickName());
        Integer rest = xjtbTbBaseService.addDkxxbXjDatadg(parm);
        if (rest > 0) {
            return AjaxResult.success("提交至市级成功", rest);
        }
        return AjaxResult.error("提交至市级失败");
    }

    //根据jcbh查询所有的dkbh
    @RequestMapping(value = "/getDkbhByJcbh", method = RequestMethod.POST)
    public AjaxResult getDkbhByJcbh(@RequestBody Map<String, Object> parm) {
        List<Map<String, Object>> rest = xjtbTbBaseService.getDkbhByJcbh(parm);
        if (rest != null) {
            return AjaxResult.success("根据jcbh查询所有的dkbh 成功", rest);
        }
        return AjaxResult.error("根据jcbh查询所有的dkbh 失败", -1);
    }

    //根据省级填报的结果生成的核查结果说明判断县级提交未通过地块
    @RequestMapping(value = "/saveXjWtgDk", method = RequestMethod.POST)
    public AjaxResult saveXjWtgDk(@RequestBody Map<String, Object> parm) {
        Integer rest = xjtbTbBaseService.saveXjWtgDk(parm);
        if (rest > 0) {
            return AjaxResult.success("根据jcbh查询所有的dkbh 成功", rest);
        }
        return AjaxResult.error("根据jcbh查询所有的dkbh 失败", -1);
    }

    //获取未通过批次号
    @RequestMapping(value = "/getWtgPch", method = RequestMethod.POST)
    public AjaxResult getWtgPch(@RequestBody Map<String, Object> parm) {
        try {
            List<Map<String, Object>> list = xjtbTbBaseService.getWtgPch(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //查询县级未通过地块
    @RequestMapping(value = "/queryXjWtgDk", method = RequestMethod.POST)
    public AjaxResult queryXjWtgDk(@RequestBody Map<String, Object> parm) {
        List<Map<String, Object>> rest = xjtbTbBaseService.queryXjWtgDk(parm);
        Integer cnt = xjtbTbBaseService.queryXjWtgDkCount(parm);
        if (rest != null) {
            return AjaxResult.success("查询县级未通过地块 成功", rest, cnt);
        }
        return AjaxResult.error("查询县级未通过地块 失败", -1);
    }

    //查询县级未通过地块
    @RequestMapping(value = "/queryXjWtgDkByIndex", method = RequestMethod.POST)
    public AjaxResult queryXjWtgDkByIndex(@RequestBody Map<String, Object> parm) {
        Map<String, Object> rest = xjtbTbBaseService.queryXjWtgDkByIndex(parm);
        if (rest != null) {
            return AjaxResult.success("成功", rest);
        }
        return AjaxResult.error("失败", -1);
    }

    //按照图斑信息
    @RequestMapping(value = "/queryUserWtgByHctbId", method = RequestMethod.POST)
    public AjaxResult queryUserWtgByHctbId(@RequestBody Map<String, Object> parm) {
        String jcbh = parm.get("jcbh") + "";
        if (jcbh.indexOf(",") != -1) {
            parm.put("jcbh", jcbh.split(",")[0]);
        }
        try {
            WpCjTbBaseinfoxjDTO wpCjTbBaseinfoxjDTO = new WpCjTbBaseinfoxjDTO();
            //获取图斑基本信息
            WpCjTbxxbxj2023DTO wpCjTbxxbxj2023DTO = xjtbTbBaseService.querytbxxByjcbh(parm);
            //获取影像
            wpCjTbBaseinfoxjDTO.setWpCjTbxxbxj2023DTO(wpCjTbxxbxj2023DTO);
            //举证照片
            ModelMap modelMap = xjtbTbBaseService.getShowImgs(parm);
            wpCjTbBaseinfoxjDTO.setModelMap(modelMap);

            //已填报地块信息
            List<WpCjDkxxbxj2023DTO> dkxxbxjWtg2023DTOS = xjtbTbBaseService.queryWpCjDkInfoByJcbh(parm);
            wpCjTbBaseinfoxjDTO.setWpCjDkxxbxj2023List(dkxxbxjWtg2023DTOS);
            return AjaxResult.success("获取成功", wpCjTbBaseinfoxjDTO);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //保存未通过地块数据
    @RequestMapping(value = "/addWtgDkData", method = RequestMethod.POST)
    public AjaxResult addWtgDkData(@RequestBody Map<String, Object> parm) {
        Integer rest = xjtbTbBaseService.addWtgDkData(parm);
        if (rest > 0) {
            return AjaxResult.success("保存未通过地块数据 成功", rest);
        }
        return AjaxResult.error("保存未通过地块数据 失败", -1);
    }

    //提交未通过地块数据
    @RequestMapping(value = "/wtgdkSubmit", method = RequestMethod.POST)
    public AjaxResult wtgdkSubmit(@RequestBody Map<String, Object> parm) {
        Integer rest = xjtbTbBaseService.wtgdkSubmit(parm);
        if (rest > 0) {
            return AjaxResult.success("提交未通过地块数据 成功", rest);
        }
        return AjaxResult.error("提交未通过地块数据 失败", -1);
    }


    //暂存
    @RequestMapping(value = "/saveDkxxbXjByDk", method = RequestMethod.POST)
    public AjaxResult saveDkxxbXjByDk(@RequestBody Map<String, Object> parm) {
        Integer rest = xjtbTbBaseService.saveDkxxbXjByDk(parm);
        if (rest > 0) {
            return AjaxResult.success("暂存 成功", rest);
        }
        return AjaxResult.error("暂存 失败", -1);
    }

    //暂存
    @RequestMapping(value = "/saveWtgDkxxbXj", method = RequestMethod.POST)
    public AjaxResult saveWtgDkxxbXj(@RequestBody Map<String, Object> parm) {
        Integer rest = xjtbTbBaseService.saveWtgDkxxbXj(parm);
        if (rest > 0) {
            return AjaxResult.success("暂存 成功", rest);
        }
        return AjaxResult.error("暂存 失败", -1);
    }


    /**
     * 资源映射路径 前缀
     */
    @Value("${file.prefix}")
    public String localFilePrefix;

    /**
     * 域名或本机访问地址
     */
    @Value("${file.domain}")
    public String domain;

    /**
     * 上传文件存储在本地的根路径
     */
    @Value("${file.path}")
    private String localFilePath;

    /**
     * 文件上传
     */
    /*@RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
    public AjaxResult avatar(MultipartFile[] files) {
        try {
            if (files == null || files.length == 0) {
                return AjaxResult.error("请选择需要上传的文件");
            } else {
                List<String> lstPaths = new ArrayList<>();
                for (MultipartFile file : files) {
                    if (!file.isEmpty()) {
                        String avatar = FileUploadUtils.upload(localFilePath, file);
                        lstPaths.add(domain + avatar);
                    }
                }
                AjaxResult ajax = AjaxResult.success();
                ajax.put("imgUrls", StringUtils.join(lstPaths, ";"));
                ajax.put("total", lstPaths.size());
                return ajax;
            }
//            if (!file.isEmpty()) {
//                // ...
//                String avatar = FileUploadUtils.upload(localFilePath, file);
//                AjaxResult ajax = AjaxResult.success();
//                ajax.put("imgUrl", avatar);
//                // ...
//                return ajax;
//            }
//            return AjaxResult.error("上传图片异常，请联系管理员");
        } catch (Exception ex) {
            return AjaxResult.error("上传图片异常，请联系管理员" + ex);
        }
    }*/
    @Transactional
    @RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
    public AjaxResult uploadFile(@RequestParam(value = "files") MultipartFile[] files,
                                 @RequestParam(value = "dkbh") String dkbh,
                                 @RequestParam(value = "pch") String pch,
                                 @RequestParam(value = "xzqdm") String xzqdm,
                                 @RequestParam(value = "fjlx") String fjlx) {
        try {
            if (files == null || files.length == 0) {
                return AjaxResult.error("请选择需要上传的文件");
            } else {
                StringBuilder sb = new StringBuilder();
                for (MultipartFile file : files) {
                    if (!file.isEmpty()) {
                        String fjurl = uploadToLocal(file, dkbh, pch, xzqdm, fjlx);
                        if (sb.length()>0) {
                            sb.append(",");
                        }
                        sb.append(fjurl);
                    } else {
                        return AjaxResult.error("上传文件有误！");
                    }
                }
                return AjaxResult.success("文件上传成功",sb.toString());
            }
        } catch (Exception ex) {
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return AjaxResult.error("上传文件异常，请联系管理员" + ex);
        }
    }

    public String uploadToLocal(MultipartFile file, String dkbh, String pch, String xzqdm, String fjlx) {
        // 获取文件原本的名字
        String originName = file.getOriginalFilename();
        // 判断文件是否是pdf文件
//        Set<String> set = new HashSet<>();
//        set.add(".pdf");
//        set.add(".doc");
//        set.add(".docx");
        // 取出文件的后缀
        int count = 0;
        for (int i = 0; i < originName.length(); i++) {
            if (originName.charAt(i) == '.') {
                count = i;
                break;
            }
        }
        String endName = originName.substring(count); //取出文件类型
        String fileType = originName.substring(count + 1); //文件类型
//        if (!set.contains(endName)) {
//            return new String("上传的文件类型错误,只能上传pdf,doc,docx类型的文件");
//        }
        // 创建保存路径
        String savePath = System.getProperty("user.dir") + "\\" + "files" + "\\" + pch + "\\" + xzqdm + "\\" + subStringByDkbh(dkbh);
        // 保存文件的文件夹
        File folder = new File(savePath);
        // 判断路径是否存在,不存在则自动创建
        if (!folder.exists()) {
            folder.mkdirs();
        }
        String saveName = originName;
        try {
            //文件存到本地
            file.transferTo(new File(folder, saveName));
            //文件地址
            String filePath = savePath + "\\" + saveName;

            String OBSAddress = "xjtb" + "/" + pch + "/" + xzqdm + "/" + subStringByDkbh(dkbh) + "/" + saveName;
            String log = OBSUploadUnits.OBSUpload(OBSAddress, filePath);
            String fjurl = "";
            if ("success".equals(log)) {
                fjurl = "https://obs-top.obs.cn-north-1.myhuaweicloud.com/" + OBSAddress;
                Map<String, Object> map = new HashMap<>();
                map.put("dkbh", dkbh);
                map.put("pch", pch);
                map.put("xzqdm", xzqdm);
                map.put("fjmc", saveName);
                map.put("fjlx", fjlx);
                map.put("fjurl", fjurl);
                xjtbTbBaseService.addFjInfo(map);
            }
            deleteFolder(folder);
            return new String(fjurl);
        } catch (IOException e) {
            return new String(e.getMessage());
        }
    }

    public static void deleteFolder(File folder) {
        if (folder.isDirectory()) {
            File[] files = folder.listFiles();
            if (files != null) {
                for (File file : files) {
                    deleteFolder(file);
                }
            }
        }
        folder.delete();
    }

    //截取三个逗号前的编号
    public String subStringByDkbh(String dkbh) {
        int index = -1;
        // 使用split方法将字符串拆分成数组
        String[] split = dkbh.split(",");
        // 判断数组长度是否大于等于3
        if (split.length >= 3) {
            // 使用String.join方法拼接前三个元素，并添加逗号
            return String.join(",", split[0], split[1], split[2]);
        } else {
            return dkbh;
        }
    }

    /**
     * 删除文件
     *
     * @param files
     * @param dkbh
     * @param pch
     * @param xzqdm
     * @param fjlx
     * @return
     */
    @RequestMapping(value = "/deleteFile", method = RequestMethod.POST)
    public AjaxResult deleteFile(@RequestParam(value = "files") MultipartFile[] files,
                                 @RequestParam(value = "dkbh") String dkbh,
                                 @RequestParam(value = "pch") String pch,
                                 @RequestParam(value = "xzqdm") String xzqdm,
                                 @RequestParam(value = "fjlx") String fjlx) {
        try {
            if (files == null || files.length == 0) {
                return AjaxResult.error("请选择需要删除的文件");
            } else {
                for (MultipartFile file : files) {
                    if (!file.isEmpty()) {
                        String saveName = file.getOriginalFilename();
                        Map<String, Object> map = new HashMap<>();
                        map.put("dkbh", dkbh);
                        map.put("pch", pch);
                        map.put("xzqdm", xzqdm);
                        map.put("fjmc", saveName);
                        map.put("fjlx", fjlx);
                        xjtbTbBaseService.deleteFjInfo(map);
                        String OBSAddress = "xjtb" + "/" + pch + "/" + xzqdm + "/" + subStringByDkbh(dkbh) + "/" + saveName;
                        OBSDeleteUnits.OBSDelete(OBSAddress);
                    }
                }
                return AjaxResult.success("文件删除成功");
            }
        } catch (Exception ex) {
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return AjaxResult.error("删除文件异常，请联系管理员" + ex);
        }
    }

    //查询流转表进度流程
    @RequestMapping(value = "/queryLz", method = RequestMethod.POST)
    public AjaxResult queryLz(@RequestBody Map<String, Object> parm) {
        List<Map<String, Object>> rest = xjtbTbBaseService.queryLz(parm);
        if (rest != null) {
            return AjaxResult.success("查询流转表进度流程 成功", rest);
        }
        return AjaxResult.error("查询流转表进度流程 失败", -1);
    }

    //查询省级退回原因
    @RequestMapping(value = "/queryThyy", method = RequestMethod.POST)
    public AjaxResult queryThyy(@RequestBody Map<String, Object> parm) {
        String rest = xjtbTbBaseService.queryThyy(parm);
        return AjaxResult.success("查询流转表进度流程 成功", rest);
    }

    //查询流转表进度流程
    @RequestMapping(value = "/queryRelatedk", method = RequestMethod.POST)
    public AjaxResult queryRelatedk(@RequestBody Map<String, Object> parm) {
        //所有相关地块
        List<Map<String, Object>> rest = xjtbTbBaseService.queryRelatedk(parm);
        //未提交的地块
        List<String> tbbhs = new ArrayList<String>();
        //已经提交的地块
        List<String> tjtbbhs1 = new ArrayList<String>();
        //图斑已经被拆分  地块没有被提交到市级
        String str = "";
        if (rest != null) {
            if (rest.size() > 0) {
                for (int i = 0; i < rest.size(); i++) {
                    String tbbh = rest.get(i).get("tbbh").toString();
                    String dkzt = rest.get(i).get("dkzt").toString();
                    if (dkzt.equals("1") || dkzt.equals("0") || dkzt.equals("4") || dkzt.equals("7")) {
                        tbbhs.add(tbbh);
                        str += "(" + rest.get(i).get("tbbh") + ")";
                    } else {
                        tjtbbhs1.add(tbbh);
                        str += "(" + rest.get(i).get("tbbh") + ")";
                    }
                }
            }
            if (rest.size() == tbbhs.size() && tjtbbhs1.size() == 0) {
                return AjaxResult.success("获取关联图斑 成功", str);
            } else {
                return AjaxResult.warn("部分地块已被提交，无法撤销", str);
            }
        }
        return AjaxResult.error("获取关联图斑 失败", -1);
    }

    @Transactional
    @RequestMapping(value = "/deleteRelatedk", method = RequestMethod.POST)
    public AjaxResult deleteRelatedk(@RequestBody Map<String, Object> parm) {
        List<Map<String, Object>> rest = xjtbTbBaseService.queryRelatetb(parm);
        //更新图斑状态
        if (rest != null && rest.size() > 0) {
            for (int i = 0; i < rest.size(); i++) {
                Map<String, Object> map = new HashMap<>();
                map.put("jcbh", rest.get(i).get("jcbh").toString());
                //更新状态
                int k = xjtbTbBaseService.updateRalateTb(map);
            }
        }

        //删除外业任务
        List<Map<String, Object>> dkList = xjtbTbBaseService.queryDkbhByTbbh(parm);
        if (dkList != null && dkList.size() > 0) {
            for (Map<String, Object> map : dkList) {
                List<Map<String, Object>> queryDelDkByWyTask = xjtbTbBaseService.queryDelDkByWyTask(parm);
                for (Map<String, Object> task : queryDelDkByWyTask) {
                    xjtbTbBaseService.updateTaskCount(task);
                }
                xjtbTbBaseService.deleteWyrwTaskdetail(map);
//                xjtbTbBaseService.deleteWyrwTaskdetailAnnex(map);
            }
        }

        //删除所有地块
        Integer k = xjtbTbBaseService.deleteRelatedk(parm);
        if (k >= 0) {
            return AjaxResult.success("撤销成功", k);
        }
        return AjaxResult.error("撤销失败", -1);
    }

    //导出图斑列表
    @RequestMapping(value = "/exportTbList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public AjaxResult exportTbList(@RequestBody Map<String, Object> parm, HttpServletResponse response) {
        String rest = "";
        String msg = "";
        ExcelUtils excel = new ExcelUtils();
        List<String> Colomnlist = new ArrayList<>();
        Colomnlist.clear();
        Colomnlist.add("序号");
        Colomnlist.add("所属省份");
        Colomnlist.add("所属市区");
        Colomnlist.add("所属区县");//qxmc
        Colomnlist.add("所属乡镇");//ssxz
        Colomnlist.add("所属村");
        Colomnlist.add("监测编号");
        Colomnlist.add("图斑来源");
        Colomnlist.add("处理状态");
        Colomnlist.add("监测面积");
        Colomnlist.add("监测图斑现状耕地面积");
        Colomnlist.add("监测图斑现状农用地总面积");
        Colomnlist.add("地类认定建设用地面积");
        Colomnlist.add("地类认定未利用地面积");
        Colomnlist.add("占基本农田面积");

//        Colomnlist.add("核查节点");
//        Colomnlist.add("是否分割地块");

        String operName = SecurityUtils.getUsername();
        parm.put("username", operName);
        //获取图斑列表
        List<WpCjTbxxbxj2023DTO> list = xjtbTbBaseService.queryTbByxzqh(parm);
        rest = excel.exportTbList(response, "图斑列表", list, Colomnlist, tempath);
        if (rest.contains("error")) {
            msg = "导出失败";
        } else {
            msg = "导出成功";
        }
        return AjaxResult.success(msg, rest);
    }

    @RequestMapping(value = "/exportShpList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public AjaxResult exportShpList(@RequestBody Map<String, Object> parm, HttpServletResponse response) throws ZipException {
        String rest = "";
        String msg = "";

        GdalUtils gdalutil = new GdalUtils();
        String operName = SecurityUtils.getUsername();
        parm.put("username", operName);
        //获取图斑列表
        List<WpCjTbxxbxj2023DTO> list = xjtbTbBaseService.queryTbByxzqh(parm);
        rest = gdalutil.exportTbList(response, list, tempath);
        if (rest.contains("error")) {
            msg = "导出失败";
        } else
        {
            List<String> arr=new ArrayList<>();
            arr.add(tempath+"\\"+rest);  //shp
            String zippath=tempath+"\\"+rest.replace("shp","zip");
            //生成了shp
            String  str=tempath+"\\"+rest.replace("shp","prj");
            File  file=new File(str);
            if(file.exists())
            {
                arr.add(str);  //prj
            }

            str=tempath+"\\"+rest.replace("shp","dbf");
            file=new File(str);
            if(file.exists())
            {
                arr.add(str);  //prj
            }
            str=tempath+"\\"+rest.replace("shp","shx");
            file=new File(str);
            if(file.exists())
            {
                arr.add(str);  //prj
            }
            rest=multipleFileUnZip.fileZip(zippath,arr);
            if(rest=="") {
                File file1=new File(zippath);
                rest=file1.getName();
                msg = "导出成功";
            }
            else
            {
                msg = "导出失败";
            }
        }
        return AjaxResult.success(msg, rest);
    }


    //导出地块列表
    @RequestMapping(value = "/exportDkList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public AjaxResult exportDkList(@RequestBody Map<String, Object> parm, HttpServletResponse response) {
        String rest = "";
        String msg = "";
        ExcelUtils excel = new ExcelUtils();
        List<String> Colomnlist = new ArrayList<>();
        Colomnlist.clear();
        Colomnlist.add("序号");
        Colomnlist.add("所属省份");
        Colomnlist.add("所属市区");
        Colomnlist.add("所属区县");
        Colomnlist.add("所属乡镇");
        Colomnlist.add("所属村");
        Colomnlist.add("地块编号");
        Colomnlist.add("监测编号");
        Colomnlist.add("核查节点");
        Colomnlist.add("判定类型");
        Colomnlist.add("具体情形");
        Colomnlist.add("实际用途");
        Colomnlist.add("判定依据说明");
        Colomnlist.add("套合地块面积");
        Colomnlist.add("套合地块耕地面积");
        Colomnlist.add("套合地块占用基本农田面积");
        Colomnlist.add("填报地块面积");
        Colomnlist.add("填报地块其中耕地面积");
        Colomnlist.add("填报地块其中基本农田面积");
        Colomnlist.add("填报农用地面积");
        Colomnlist.add("填报地块水田面积");
        Colomnlist.add("填报地块生态保护红线面积");

        Colomnlist.add("市级审核结果");
        Colomnlist.add("市级核查说明");
        Colomnlist.add("市级审核用户");
        Colomnlist.add("市级审核人员");
        Colomnlist.add("省级审核结论");
        Colomnlist.add("省级核查说明");
        Colomnlist.add("省级审核用户");
        Colomnlist.add("省级审核人员");

        Colomnlist.add("农用地转用批准文号");
        Colomnlist.add("农用地转用批文来源");
        Colomnlist.add("农用地转用批准面积");
        Colomnlist.add("农用地转用批准机关");
        Colomnlist.add("农用地转用批准日期");
        Colomnlist.add("增减挂钩批准文号");
        Colomnlist.add("增减挂钩批文来源");
        Colomnlist.add("增减挂钩批准面积");
        Colomnlist.add("增减挂钩批准机关");
        Colomnlist.add("增减挂钩批准日期");
        Colomnlist.add("工矿废弃地批准文号");
        Colomnlist.add("工矿废弃地批文来源");
        Colomnlist.add("工矿废弃地批准面积");
        Colomnlist.add("工矿废弃地批准机关");
        Colomnlist.add("工矿废弃地批准日期");
        Colomnlist.add("不动产权证书批准文号");
        Colomnlist.add("不动产权证书批准来源");
        Colomnlist.add("不动产权证书批准面积");
        Colomnlist.add("不动产权证书批准机关");
        Colomnlist.add("不动产权证书批准日期");
        Colomnlist.add("设施农用地批准文号");
        Colomnlist.add("设施农用地批准来源");
        Colomnlist.add("设施农用地批准面积");
        Colomnlist.add("设施农用地批准机关");
        Colomnlist.add("设施农用地批准日期");
        Colomnlist.add("土地整治验收批准文号");
        Colomnlist.add("土地整治验收批准来源");
        Colomnlist.add("土地整治验收批准面积");
        Colomnlist.add("土地整治验收批准机关");
        Colomnlist.add("土地整治验收批准日期");
        Colomnlist.add("其他批准文号");
        Colomnlist.add("其他批准来源");
        Colomnlist.add("其他批准面积");
        Colomnlist.add("其他批准机关");
        Colomnlist.add("其他批准日期");
        Colomnlist.add("临时用地批准文号");
        Colomnlist.add("临时用地批准来源");
        Colomnlist.add("临时用地批准面积");
        Colomnlist.add("临时用地批准机关");
        Colomnlist.add("临时用地批准日期");
        Colomnlist.add("土地供应批准文号");
        Colomnlist.add("土地供应批准来源");
        Colomnlist.add("土地供应批准面积");
        Colomnlist.add("土地供应批准机关");
        Colomnlist.add("土地供应批准日期");
        Colomnlist.add("先行用地批准文号");
        Colomnlist.add("先行用地批准来源");
        Colomnlist.add("先行用地批准面积");
        Colomnlist.add("先行用地批准机关");
        Colomnlist.add("先行用地批准日期");
        Colomnlist.add("预审批准文号");
        Colomnlist.add("预审批准来源");
        Colomnlist.add("预审批准面积");
        Colomnlist.add("预审批准机关");
        Colomnlist.add("预审批准日期");
        String operName = SecurityUtils.getUsername();
        parm.put("username", operName);
        //获取图斑列表
//        List<YtbTbInfo> list = xjtbTbBaseService.queryYtbTbInfo(parm);
        List<YtbTbInfo> list = xjtbTbBaseService.queryExportDkList(parm);
        rest = excel.exportDkList(response, "地块列表", list, Colomnlist, tempath);
        if (rest.contains("error")) {
            msg = "导出失败";
        } else {
            msg = "导出成功";
        }
        return AjaxResult.success(msg, rest);
    }


    @RequestMapping(value = "/exportDkShpList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public AjaxResult exportDkShpList(@RequestBody Map<String, Object> parm, HttpServletResponse response) throws ZipException {
        String rest = "";
        String msg = "";
        GdalUtils gdalutil = new GdalUtils();
        String operName = SecurityUtils.getUsername();
        parm.put("username", operName);
        //获取图斑列表
        List<YtbTbInfo> list = xjtbTbBaseService.queryYtbTbInfo(parm);
        rest = gdalutil.exportDkList(response,list, tempath);
        if (rest.contains("error")) {
            msg = "导出失败";
        } else {
            List<String> arr=new ArrayList<>();
            arr.add(tempath+"\\"+rest);  //shp
            String zippath=tempath+"\\"+rest.replace("shp","zip");
            //生成了shp
            String  str=tempath+"\\"+rest.replace("shp","prj");
            File  file=new File(str);
            if(file.exists())
            {
                arr.add(str);  //prj
            }

            str=tempath+"\\"+rest.replace("shp","dbf");
            file=new File(str);
            if(file.exists())
            {
                arr.add(str);  //prj
            }
            str=tempath+"\\"+rest.replace("shp","shx");
            file=new File(str);
            if(file.exists())
            {
                arr.add(str);  //prj
            }
            rest=multipleFileUnZip.fileZip(zippath,arr);
            if(rest=="") {
                File file1=new File(zippath);
                rest=file1.getName();
                msg = "导出成功";
            }
            else
            {
                msg = "导出失败";
            }
        }
        return AjaxResult.success(msg, rest);
    }

    //照片信息 图斑
    @RequestMapping(value = "/getImgInfo", method = RequestMethod.POST)
    public AjaxResult getImgInfo(@RequestBody Map<String, Object> parm) {
        WpCjGsinfoly2024DTO gsinfoly = xjtbTbBaseService.getGsinfoly(parm);
        String rest = "";
        if ("1".equals(gsinfoly.getInfoly())) {
            rest = appService.getInfo(parm);
            return AjaxResult.success("照片信息获取 成功", rest);
        }
        else
        {
            return AjaxResult.success("照片信息获取 成功", rest);
        }
    }

    //修改照片所属地块
    @RequestMapping(value = "/updateImgInfo", method = RequestMethod.POST)
    public AjaxResult updateImgInfo(@RequestBody Map<String, Object> parm) {
        Integer rest = xjtbTbBaseService.updateImgInfo(parm);
        if (rest > 0) {
            return AjaxResult.success("修改照片所属地块 成功", rest);
        }
        return AjaxResult.error("修改照片所属地块 失败", -1);
    }

    //删除照片
    @RequestMapping(value = "/deleteImg", method = RequestMethod.POST)
    public AjaxResult deleteImg(@RequestBody Map<String, Object> parm) {
        Integer rest = xjtbTbBaseService.deleteImg(parm);
        if (rest > 0) {
            return AjaxResult.success("删除照片 成功", rest);
        }
        return AjaxResult.error("删除照片 失败", -1);
    }

    //查询删除图片
    @RequestMapping(value = "/queryDeleteImg", method = RequestMethod.POST)
    public AjaxResult queryDeleteImg(@RequestBody Map<String, Object> parm) {
        List<Map<String, Object>> rest = xjtbTbBaseService.queryDeleteImg(parm);
        return AjaxResult.success("查询删除图片 成功", rest);
    }

    //县级 查看 不通过地块 dkzt 4 7
    //市 查看 不通过地块 dkzt 5
    //省 查看 不通过地块 dkzt 6
    @RequestMapping(value = "/queryXjBtgdk", method = RequestMethod.POST)
    public AjaxResult queryXjBtgdk(@RequestBody Map<String, Object> parm) {
        try {
            List<YtbTbInfo> list = xjtbTbBaseService.queryXjBtgdk(parm);
            Integer cnt = xjtbTbBaseService.queryXjBtgdkCount(parm);
            return AjaxResult.success("不通过地块 成功", list, cnt);
        } catch (Exception ex) {
            return AjaxResult.error("不通过地块 失败", ex.toString());
        }
    }

    @RequestMapping(value = "/saveXjBtgdk", method = RequestMethod.POST)
    public AjaxResult saveXjBtgdk(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("czr", loginUser.getUsername());
            parm.put("realname", loginUser.getSysUser().getNickName());
            Integer rest = xjtbTbBaseService.saveXjBtgdk(parm);
            return AjaxResult.success("不通过地块 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("不通过地块 失败", ex.toString());
        }
    }

    //获取附件信息
    @RequestMapping(value = "/getFlieInfo", method = RequestMethod.POST)
    public AjaxResult getFlieInfo(@RequestBody Map<String, Object> parm) throws Exception {
        WpCjGsinfoly2024DTO gsinfoly = xjtbTbBaseService.getGsinfoly(parm);
        List<Map<String, Object>> rest = new ArrayList<>();
        if ("1".equals(gsinfoly.getInfoly())) {
            rest = appService.getFlieInfo(parm);
            for (int i = 0; i < rest.size(); i++) {
                String fjUrl = rest.get(i).get("fj").toString();
                rest.get(i).put("fjurl1", downloadFile(fjUrl, "preview"));
            }
        }
        if (rest != null) {
            return AjaxResult.success("照片信息获取 成功", rest);
        } else {
            return AjaxResult.error("照片信息获取 失败", -1);
        }
    }

    public String downloadFile(String fileUrl,String action) throws Exception {
        OkHttpClient client = new OkHttpClient();

        Request.Builder requestBuilder = new Request.Builder().url(fileUrl);
        String fileName = fileUrl.substring(fileUrl.lastIndexOf('/') + 1);
        // 设置请求头
        if ("download".equals(action)) {
            requestBuilder.addHeader("Content-Disposition", "attachment; filename=pdf-file.pdf");
        } else {
            requestBuilder.addHeader("Content-Disposition", "inline; filename=pdf-file.pdf");
        }

        Request request = requestBuilder.build();
        Response response = client.newCall(request).execute();
        String saveFilePath = tempath + "\\" + fileName;  // 存储路径  // 存储路径
        if (response.isSuccessful()) {
            InputStream inputStream = response.body().byteStream();


            FileOutputStream outputStream = new FileOutputStream(saveFilePath);
            byte[] buffer = new byte[1024];
            int bytesRead;
            while ((bytesRead = inputStream.read(buffer)) != -1) {
                outputStream.write(buffer, 0, bytesRead);
            }

            outputStream.close();
            inputStream.close();
            return saveFilePath;
//        URL url = new URL(fileUrl);
//        HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
//        String file = url.getFile();
//        String fileName = file.substring(file.lastIndexOf('/') + 1);
//        // 设置请求头
//        if ("download".equals(action)) {
//            httpConn.setRequestProperty("Content-Disposition", "attachment; filename="+fileName);
//        } else {
//            httpConn.setRequestProperty("Content-Disposition", "inline; filename="+fileName);
//        }
//        httpConn.setConnectTimeout(3000);
//        // 限制输入流等待数据到达的时间，超时将会抛出java.net.SocketTimeoutException
//        httpConn.setReadTimeout(3000);
//        // 设定请求的方法为"POST"，默认是GET
//        httpConn.setRequestMethod("POST");
//        // 设置传送的内容类型是json格式
//        httpConn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
//        // 接收的内容类型也是json格式
//        httpConn.setRequestProperty("Accept", "application/json;charset=utf-8");
//        // 设置是否从httpUrlConnection读入，默认情况下是true
//        httpConn.setDoInput(true);
//        // 由于URLConnection在默认的情况下不允许输出，所以在请求输出流之前必须调用setDoOutput(true)。为一个HTTP URL将doOutput设置为true时，请求方法将由GET变为POST
//        httpConn.setDoOutput(true);
//        // 是否使用缓存，Post方式不能使用缓存
//        httpConn.setUseCaches(false);
//
//        InputStream inputStream = httpConn.getInputStream();
//        String saveFilePath = tempath+"\\"+fileName;  // 存储路径
//
//        FileOutputStream outputStream = new FileOutputStream(saveFilePath);
//        BufferedInputStream bis = new BufferedInputStream(inputStream);
//        byte[] buffer = new byte[1024];
//        int bytesRead;
//        while ((bytesRead = bis.read(buffer)) != -1) {
//            outputStream.write(buffer, 0, bytesRead);
//        }
//
//        outputStream.close();
//        bis.close();
//        inputStream.close();
//        httpConn.disconnect();
//
//
        }
        return saveFilePath;
    }
    //删除文件
    @RequestMapping(value = "/deleteFjInfo", method = RequestMethod.POST)
    @Transactional
    public AjaxResult deleteFjInfo(@RequestBody Map<String, Object> parm) {
        Integer rest = xjtbTbBaseService.deleteFjInfo(parm);
        String OBSAddress = "xjtb" + "/" + parm.get("pch") + "/" + parm.get("xzqdm") + "/" + subStringByDkbh(parm.get("dkbh") + "") + "/" + parm.get("fjmc");
        String obs = OBSDeleteUnits.OBSDelete(OBSAddress);
        if (rest > 0 && "success".equals(obs)) {
            parm.put("OBSAddress",OBSAddress);
            xjtbTbBaseService.deleteDkxjPwFj(parm);
            return AjaxResult.success("删除文件 成功", rest);
        } else {
            return AjaxResult.error("删除文件 失败", -1);
        }
    }

    @RequestMapping(value = "/queryFjInfoByName", method = RequestMethod.POST)
    public AjaxResult queryFjInfoByName(@RequestBody Map<String, Object> parm) {
        List<Map<String, Object>> rest = xjtbTbBaseService.queryFjInfoByName(parm);
        return AjaxResult.success("查询 成功", rest);
    }

    @RequestMapping(value = "/queryZjggjxByPzwh", method = RequestMethod.POST)
    public AjaxResult queryZjggjxByPzwh(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("xzqdm", loginUser.getSysUser().getXzqdm());
        List<Map<String, Object>> rest = xjtbTbBaseService.queryZjggjxByPzwh(parm);
        return AjaxResult.success("查询 成功", rest);
    }

    @RequestMapping(value = "/queryPwByPzwh", method = RequestMethod.POST)
    public AjaxResult queryPwByPzwh(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("xzqdm", loginUser.getSysUser().getXzqdm());
        List<Map<String, Object>> rest = xjtbTbBaseService.queryPwByPzwh(parm);
        return AjaxResult.success("查询 成功", rest);
    }

    @RequestMapping(value = "/getGsinfoly", method = RequestMethod.POST)
    public AjaxResult getGsinfoly(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("xzqdm", loginUser.getSysUser().getXzqdm());
        WpCjGsinfoly2024DTO rest = xjtbTbBaseService.getGsinfoly(parm);
        return AjaxResult.success("查询 成功", rest);
    }



}
